#!/usr/bin/env python3

# Copyright (c) 2020-2021 Fpemud <fpemud@sina.com>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.


import enum


class Arch(enum.Enum):
    X86 = "x86"
    X86_64 = "x86_64"


class Version(enum.Enum):
    WINDOWS_95 = "windows_95"
    WINDOWS_98 = "windows_98"
    WINDOWS_XP = "windows_xp"
    WINDOWS_VISTA = "windows_vista"
    WINDOWS_7 = "windows_7"
    WINDOWS_8 = "windows_8"
    WINDOWS_8_1 = "windows_8.1"
    WINDOWS_10 = "windows_10"
    WINDOWS_11 = "windows_11"

    WINDOWS_SERVER_2003 = "windows_server_2003"
    WINDOWS_SERVER_2008 = "windows_server_2008"
    WINDOWS_SERVER_2012 = "windows_server_2012"
    WINDOWS_SERVER_2016 = "windows_server_2016"
    WINDOWS_SERVER_2019 = "windows_server_2019"


class Edition(enum.IntEnum):
    # from https://en.wikipedia.org/wiki/Microsoft_Windows_version_history
    WINDOWS_95 = enum.auto()                   # Windows 95

    # from https://en.wikipedia.org/wiki/Microsoft_Windows_version_history
    WINDOWS_98 = enum.auto()                   # Windows 98
    WINDOWS_98_SE = enum.auto()                # Windows 98 SE

    WINDOWS_XP_HOME = enum.auto()
    WINDOWS_XP_PROFESSIONAL = enum.auto()

    WINDOWS_VISTA = enum.auto()

    # from https://www.windowsafg.com
    WINDOWS_7_STARTER = enum.auto()            # Windows 7 Starter
    WINDOWS_7_HOME_BASIC = enum.auto()         # Windows 7 Home Basic
    WINDOWS_7_HOME_PREMIUM = enum.auto()       # Windows 7 Home Premium
    WINDOWS_7_PROFESSIONAL = enum.auto()       # Windows 7 Professional
    WINDOWS_7_ULTIMATE = enum.auto()           # Windows 7 Ultimate
    WINDOWS_7_ENTERPRISE = enum.auto()         # Windows 7 Enterprise

    # from https://www.windowsafg.com
    WINDOWS_8 = enum.auto()                    # Windows 8
    WINDOWS_8_PRO = enum.auto()                # Windows 8 Pro
    WINDOWS_8_PRO_MC = enum.auto()             # Windows 8 Pro with Media Center
    WINDOWS_8_ENTERPRISE = enum.auto()         # Windows 8 Enterprise

    # from https://www.windowsafg.com
    WINDOWS_8_1 = enum.auto()                  # Windows 8.1
    WINDOWS_8_1_PRO = enum.auto()              # Windows 8.1 Pro
    WINDOWS_8_1_PRO_MC = enum.auto()           # Windows 8.1 Pro with Media Center
    WINDOWS_8_1_ENTERPRISE = enum.auto()       # Windows 8.1 Enterprise

    # from https://www.windowsafg.com
    WINDOWS_10_HOME = enum.auto()              # Windows 10 Home
    WINDOWS_10_PRO = enum.auto()               # Windows 10 Pro
    WINDOWS_10_EDUCATION = enum.auto()         # Windows 10 Education
    WINDOWS_10_ENTERPRISE = enum.auto()        # Windows 10 Enterprise
    WINDOWS_10_ENTERPRISE_LTSB = enum.auto()   # Windows 10 Enterprise LTSB

    WINDOWS_11 = enum.auto()

    # from https://www.windowsafg.com
    WINDOWS_SERVER_2008 = enum.auto()
    WINDOWS_SERVER_2012 = enum.auto()
    WINDOWS_SERVER_2016 = enum.auto()
    WINDOWS_SERVER_2019 = enum.auto()


class Lang(enum.IntEnum):
    en_US = enum.auto()
    zh_CN = enum.auto()
    zh_TW = enum.auto()


def get_archs_by_version(version):
    d = {
        Version.WINDOWS_98: [
            Arch.X86
        ],
        Version.WINDOWS_XP: [
            Arch.X86,
            Arch.X86_64
        ],
        Version.WINDOWS_7: [
            Arch.X86,
            Arch.X86_64
        ],
    }
    return d[version]


def get_editions_by_version(version):
    d = {
        Version.WINDOWS_98: [
            Edition.WINDOWS_98,
            Edition.WINDOWS_98_SE
        ],
        Version.WINDOWS_XP: [
            Edition.WINDOWS_XP_HOME,
            Edition.WINDOWS_XP_PROFESSIONAL
        ],
        Version.WINDOWS_7: [
            Edition.WINDOWS_7_STARTER,
            Edition.WINDOWS_7_HOME_BASIC,
            Edition.WINDOWS_7_HOME_PREMIUM,
            Edition.WINDOWS_7_PROFESSIONAL,
            Edition.WINDOWS_7_ULTIMATE,
            Edition.WINDOWS_7_ENTERPRISE
        ],
    }
    return d[version]
